<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>offset([coordinates])</title>
<link type="text/css" rel="stylesheet" href="style/style.css" tppabs="http://www.erdangjiade.com/manual/jquery/jquery/style/style.css"  />
</head>
<body id="split">
<div id="content">
  <div rel="offset">
    <h2><span>返回值:Object{top,left}</span>offset([coordinates])</h2>
    <h3>概述</h3>
    <div class="desc">
      <p>获取匹配元素在当前视口的相对偏移。</p>
      <div class="longdesc">
        <p>返回的对象包含两个整型属性：top 和 left。此方法只对可见元素有效。</p>
      </div>
    </div>
    <h3>参数</h3>
    <div>
      <h4><strong>coordinates</strong><span>Object{top,left}, function(index, coords) </span><em>V1.2</em></h4>
      <p>一个对象，必须包含top和left属性，作为元素的新坐标。这个参数也可以是一个返回一对坐标的函数，函数的第一个参数是元素的索引，第二个参数是当前的坐标。</p>
    </div>
    <div class="example">
      <h3>示例</h3>
      <span id="f_ad2"></span>
      <h4>无参数描述:</h4>
      <p>获取第二段的偏移</p>
      <h5>HTML 代码:</h5>
      <pre><code>&lt;p&gt;Hello&lt;/p&gt;&lt;p&gt;2nd Paragraph&lt;/p&gt;</code></pre>
      <h5>jQuery 代码:</h5>
      <pre><code>var p = $("p:last");
var offset = p.offset();
p.html( "left: " + offset.left + ", top: " + offset.top );</code></pre>
      <h5>结果:</h5>
      <pre><code>&lt;p&gt;Hello&lt;/p&gt;&lt;p&gt;left: 0, top: 35&lt;/p&gt;</code></pre>
      <h4>参数coordinates 描述:</h4>
      <p>获取第二段的偏移</p>
      <h5>HTML 代码:</h5>
      <pre><code>&lt;p&gt;Hello&lt;/p&gt;&lt;p&gt;2nd Paragraph&lt;/p&gt;</code></pre>
      <h5>jQuery 代码:</h5>
      <pre><code>$("p:last").offset({ top: 10, left: 30 });</code></pre>
    </div>
  </div>
</div>
</body>
</html>
<div style="display:none">

<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F327b016d332d3a7e4043796cab725707' type='text/javascript'%3E%3C/script%3E"));
</script>
</div>